home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------*/
- /* An ARexx script to install a patch with handlepatch
-
- (C)1994 by Heinz Wrobel, for Joan Thuesen
-
- */
- /*------------------------------------------------------------------------*/
- options failat 10
-
- /*------------------------------------------------------------------------*/
- vers = '$VER: InstallPatch 37.0 (05.06.94)'
- title = trim(substr(vers, 7) "(C)1994 Heinz Wrobel, For Joan Thuesen")
- cls = '1b'x || '[0;0H' || '1b'x || '[J'
-
- unarc = 'lha -a -q -r x'
- tmpdir = 'T:PatchTemp'
- pinfo = '.patchinfo'
-
- /*------------------------------------------------------------------------*/
- options results
- address command
-
- if ~show('L', 'rexxsupport.library') then do
- if ~addlib('rexxsupport.library', 0, -30) then do
- say 'Please install the rexxsupport.library in your LIBS: directory'
- exit(20)
- end
- end
-
- /*------------------------------------------------------------------------*/
- if ~exists(pinfo) then do
- say "The file" pinfo "is missing!"
- exit(20)
- end
-
- call writech('STDOUT', cls)
- say ""
- say title
- say copies("=", length(title))
-
- say ""
-
- if (open('i', pinfo, 'R')) then do
- patchdesc = trim(readln('i'))
- srcarcname = trim(readln('i'))
- srcfullname = trim(readln('i'))
- destfullname = trim(readln('i'))
-
- say "'" || patchdesc ||"'"
- say ""
-
- do while ~eof('i')
- line = readln('i')
- i = index(line, '%SA%')
- do while i > 0
- line = left(line, i - 1) || srcarcname || substr(line, i + 4)
- i = index(line, '%SA%')
- end
-
- i = index(line, '%SF%')
- do while i > 0
- line = left(line, i - 1) || srcfullname || substr(line, i + 4)
- i = index(line, '%SF%')
- end
-
- i = index(line, '%DF%')
- do while i > 0
- line = left(line, i - 1) || destfullname || substr(line, i + 4)
- i = index(line, '%DF%')
- end
-
- say line
- end
- call close('i')
-
- call writech('STDOUT', 'Press <RETURN> after reading: ')
- pull dummy
- say ""
- end
- else
- do
- say "Could not open" pinfo
- exit(20)
- end
-
- /*------------------------------------------------------------------------*/
- call writech('STDOUT', cls)
- say ""
- say title
- say copies("=", length(title))
-
- say ""
- say "'" || patchdesc ||"'"
- say ""
-
- say "Please specify the full pathname for the source archive"
- say "named '" || srcarcname || "' or the base directory name that"
- say "contains the unchanged archive contents in unpacked form."
- say ""
- say "If the archive can't be found in the specified directory, it is"
- say "assumed to be the base of the unpacked archive contents."
- say ""
- call writech('STDOUT', 'Your input: ')
- pull SourceArc
- SourceArc = trim(SourceArc)
-
- if ~exists(SourceArc) then do
- say "Could not find" SourceArc
- exit(20)
- end
-
- say ""
- say "Now specify where to put the patched tree (the destination)."
- say "Source and destination may not be the same!"
- say ""
- call writech('STDOUT', 'Your input: ')
- pull DestDir
- DestDir = trim(DestDir)
-
- if(SourceArc = DestDir) then do
- say ""
- say "I told you! You may not have the same source and destination!"
- exit(20)
- end
-
- if ~exists(DestDir) then do
- say ""
- say "Creating" DestDir "..."
- call makedir(DestDir)
- end
-
- od = pragma(D, SourceArc)
- if exists(srcarcname) then do
- say ""
- say "Unpacking source archive to" tmpdir "..."
- if ~exists(tmpdir) then do
- call makedir(tmpdir)
- end
- olddir = pragma(D, tmpdir)
- address command 'delete >NIL: #? all quiet force'
- address command unarc mkfilename(SourceArc,srcarcname)
- call pragma(D, olddir)
- SourceArc = tmpdir
- end
- call pragma(D, od)
-
- /*------------------------------------------------------------------------*/
- say ""
- say "Creating patch in" DestDir "..."
- say ""
- address command 'handlepatch quiet patchdir "" from' SourceArc 'to' DestDir
-
- if (SourceArc = tmpdir) then do
- address command 'delete >NIL:' tmpdir 'all quiet force'
- end
-
- say "The patched files are now in" DestDir || ". Please copy them"
- say "to their final destination."
-
- exit(0)
-
- /*------------------------------------------------------------------------*/
- /* Put together a file name with the correct separators */
- mkfilename: procedure
- parse arg pathpart,file
-
- ot = trace(off)
- if length(pathpart) > 0 then do
- c = right(pathpart, 1)
- if c ~= '/' & c ~= ':' then do
- pathpart = pathpart || '/'
- end
-
- file = pathpart || file
- end
- ot = trace(ot)
-
- return(file)
-
- /*------------------------------------------------------------------------*/
-
- /* Ende des Quelltextes */
-
-